package com.jc.camerascan.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.xuexiang.xui.utils.DensityUtils;
import com.xuexiang.xui.utils.Utils;

/**
 * @ProjectName: PhotoRecognition
 * @Package: com.jc.camerascan.utils
 * @ClassName: ImageUtil
 * @Description: 图片加载工具类
 * @Author: XuChi
 * @CreateDate: 2020/7/14 16:58
 * @Version: 1.0
 */
public class ImageUtil {

    public static void loadImage(Context mContext, String url, ImageView userAvatar) {
        RequestOptions options = new RequestOptions();
            Glide.with(mContext)
                    .load(url).apply(options).thumbnail(0.1f).into(userAvatar);
    }

    public static void loadImage(Context mContext, int url, ImageView userAvatar) {
        RequestOptions options = new RequestOptions();
        Glide.with(mContext)
                .load(url).apply(options).thumbnail(0.1f).into(userAvatar);
    }

    public static void loadBlurImage(Context mContext, String url, ImageView userAvatar) {
        RequestOptions options = new RequestOptions();
        options.override(Utils.getScreenWidth(mContext), DensityUtils.dp2px(mContext, 210)).centerCrop();
        options.bitmapTransform(new BlurTransformation(1, 1));
        Glide.with(mContext)
                .load(url).apply(options).into(userAvatar);

    }
}
